package controller;

import java.util.Collection;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.doa.Doa;
import com.doa.DoaPerson;
import com.doa.beans.Person;
import com.opensymphony.xwork2.ActionSupport;

public class ListAllController extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String execute() {
		String path = ServletActionContext.getServletContext().getRealPath("/");		
		HttpServletRequest request = ServletActionContext.getRequest();
		Doa doaPerson = DoaPerson.getInstance();
		doaPerson.setPath(path);
		@SuppressWarnings("unchecked")
		Collection<Person> list = (Collection<Person>) doaPerson.listAll();
		if (list != null)
			request.setAttribute("list", list);
		return "success";
	}

}
